﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DatabaseRepository;
using Models;

namespace BusinessLogic
{
    public class DatabaseHandler : IDatabaseHandler
    {
        private readonly IUserRepository _userRepository;
        private readonly INewsRepository _newsRepository;
        private readonly IImageRepository _imageRepository;

        public DatabaseHandler(IUserRepository userRepository, INewsRepository newsRepository, IImageRepository imageRepository)
        {
            _userRepository = userRepository;
            _newsRepository = newsRepository;
            _imageRepository = imageRepository;
        }

        public bool CreateUser(string username, string password) {
            return _userRepository.CreateUser(username, password);
        }

        public IEnumerable<News> GetNewsPosts()
        {
            return _newsRepository.GetNewsPosts();
        }


        public string[] GetRoles(string username)
        {
            return _userRepository.GetRoles(username);
        }


        public bool ValidateUser(string username, string password)
        {
            return _userRepository.ValidateUser(username, password);
        }


        public bool SaveImage(string name, string url)
        {
            return _imageRepository.SaveImage(name, url);
        }

        public string GetUrl(string name)
        {
            return _imageRepository.GetUrl(name);
        }

        public IEnumerable<Images> GetImagelist()
        {
            return _imageRepository.GetImagelist();
        }


        public bool DeleteImage(string id)
        {
            return _imageRepository.DeleteImage(id);
        }


        public bool AddNews(string headline, string text)
        {
            return _newsRepository.AddNews(headline, text);
        }

        public bool DeleteNews(string id) {
            return _newsRepository.DeleteNews(id);
        }

        public bool EditNews(string id, string headline, string message) {
            return _newsRepository.EditNews(id, headline, message);
        }
    }
}
